# #? 封装一个函数 验证一个年是否是闰年
'''
def leap_year(num):
    if (num%4 ==0 and num%100 !=0) or num%400 ==0:
        print(f"{num} 是一个闰年~")
    else:
        print(f"{num} 不是闰年~")
num_year = int(input())
leap_year(num_year)
'''
#? 封装一个函数 获取指定月的天数
'''
def month_days(year):
    if (year%4 ==0 and year%100 !=0) or year%400 ==0:
        return "闰年"
    else:
        return "平年"
that_year = int(input())
that_month = int(input())
three_one = [1,3,5,7,8,10,12]
three_zero = [4,6,9,11]
date = month_days(that_year)

if date == "闰年":
    if that_month in three_one:
        print(f"闰年{that_month}月份的天数是31天")
    elif that_month == 2:
        print(f"闰年2月份的天数是29天")
    elif that_month in three_zero:
        print(f"闰年{that_month}月份的天数是30天")

elif date =="平年":
    if that_month in three_one:
        print(f"平年{that_month}月份的天数是31天")
    elif that_month == 2:
        print(f"平年2月份的天数是28天")
    elif that_month in three_zero:
        print(f"平年{that_month}月份的天数是30天")
'''
#? 封装一个函数 获取指定月所属的季节
'''
month_season = [
    {"春季":[3,4,5]},
    {"夏季":[6,7,8]},
    {"秋季":[9,10,11]},
    {"冬季":[12,1,2]}
]
month = int(input())
for ele in month_season:
    for k,v in ele.items():
        if month in v:
            print(f"{month}月份所在的季节是{k}")
'''
#? 封装一个函数 验证指定数是否是质数
'''
def Prime_num(num):
    sum = 1
    for i in range(2,num+1):
        if  num%i ==0:
            sum +=1
    return sum
number = int(input())
if number >1:
    if Prime_num(number) == 2:
        print(f"{number} 是一个质数")
    else:
        print(f"{number} 不是一个质数")
else:
    print("请输入大于1的数字")
'''
#? 5.封装一个函数 验证一个数是否是回文
'''
def judge_repeat_num(num):
    num_t = num
    num_p = 0
    while num != 0:
        num_p = num_p * 10 + num % 10
        num = num // 10
    if num_t == num_p:
        print(f"{num_t}是一个回文数")
    else:
        print("{}不是一个回文数".format(num_t))

judge_repeat_num(12321)
'''
'''
#? 封装一个函数，获取多个数中的最大值和平均值
def dispose_num(number):
    print(f"最大值是：{max(number)}")
    print(f"平均值是：{sum(number)/len(number)}")
num = list(map(int,input().split()))
dispose_num(num)
'''
#? 封装一个函数 获取多个数中的平均值并统计其中高于平均数的值个数
'''
def average_num(num_list):
    avg = sum(num_list)/len(num_list)
    count  = 0
    for i in num_list:
        if i > avg:
            count +=1
    print(f"平均值是：{avg}")
    print(f"高于平均数的值个数{count}")
num = list(map(int,input().split()))
average_num(num)
'''

#? 8.封装一个函数，获取所有的水仙花数
def Daffodil_number(num):
    num_A = num%10
    num_B = num//10%10
    num_C = num//100
    if num == (num_A**3+num_B**3+num_C**3):
        print(f"{num}是一个水仙花数")
    else:
        print(f"{num}不是一个水仙花数")
check_num = int(input("请输入一个三位数： "))
Daffodil_number(check_num)

#? 模拟列表中sort的使用，对列表进行排序，默认升序，也可以降序
def bubble(arr,size,desc):
    for i in range(1,size,1):
        for j in range(0,size-i,1):
            if  not desc:
                if arr[j]> arr[j+1]:
                    swap(arr,j,j+1)
                else:
                    pass
            else:
                (arr[j],arr[j+1])=desc(arr[j],arr[j+1])
    print(arr)
def desc(x,y):
    if x>y:
        return x,y
    else:
        return y,x

def swap(arr,i,j):
    temp=arr[i]
    arr[i]=arr[j]
    arr[j]=temp
bubble([1,2,3,4,6,5],6,desc)